// util/FileTypeValidator.java
package com.caregiver.watch.business.file.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;

import java.util.Arrays;
import java.util.List;

@Slf4j
public final class FileTypeValidatorUtils {

    // 支持的图片类型
    private static final List<String> SUPPORTED_IMAGE_TYPES = Arrays.asList(
            "image/jpeg", "image/png", "image/gif", "image/bmp", "image/webp"
    );

    // 支持的音频类型
    private static final List<String> SUPPORTED_AUDIO_TYPES = Arrays.asList(
            "audio/mpeg", "audio/wav", "audio/ogg", "audio/mp4", "audio/x-m4a"
    );

    public static boolean isImage(MultipartFile file) {
        String contentType = file.getContentType();
        log.info("contentType: {}", contentType);
        return contentType != null && SUPPORTED_IMAGE_TYPES.contains(contentType.toLowerCase());
    }

    public static boolean isAudio(MultipartFile file) {
        String contentType = file.getContentType();
        log.info("contentType: {}", contentType);
        return contentType != null && SUPPORTED_AUDIO_TYPES.contains(contentType.toLowerCase());
    }
}